Component({
  data: { 
    selected: 0,
    list: [
      {
        pagePath: "/pages/index/index",
        text: "首页",
        icon: 'fire-o',
      },
      {
        pagePath: "/pages/course/course",
        text: "课程",
        icon: 'star-o',
      },
      {
        pagePath: "/pages/moment/moment",
        text: "农友圈",
        icon: 'friends-o',
      },
      {
        pagePath: "/pages/message/message",
        text: "消息",
        icon: 'chat-o',
      },
      {
        pagePath: "/pages/user/user",
        text: "我的",
        icon: 'user-o',
      }
    ]
  },
  methods: {
    onChange(e) {
       console.log(e,'e')
       this.setData({ active: e.detail });
       wx.switchTab({
         url: this.data.list[e.detail].pagePath
       });
    },
    init() {
        const page = getCurrentPages().pop();
        this.setData({
       　  active: this.data.list.findIndex(item => item.pagePath === `/${page.route}`)
        });
       }
    }
})